package tk.djcrazy.instantmessage.action;

import java.util.Map;

import javax.annotation.Resource;

import org.apache.struts2.interceptor.SessionAware;

import tk.djcrazy.instantmessage.domain.UserEntity;
import tk.djcrazy.instantmessage.service.IFriendshipService;
import tk.djcrazy.instantmessage.service.IUserService;

import com.opensymphony.xwork2.ActionSupport;

public class GetUserInfoAction extends ActionSupport implements SessionAware{
 	private static final long serialVersionUID = 7119991625629502853L;
 	private String viewNickName;
 	private int viewGroupId;
 	private UserEntity user;
 	private int userId;
 	private Map<String, Object> session;
  	@Resource
 	IUserService userService;
  	
  	@Resource
  	IFriendshipService friendshipService;
  	
 	public String execute() {
 		try {
 		viewNickName = friendshipService.findFriendShip((Integer) session.get("uid"), userId).getNickName();
 		user = userService.findById(userId);
		return SUCCESS;
 		}catch (Exception e) {
 			e.printStackTrace();
 			return ERROR;
 		}
	}


	public String getViewNickName() {
		return viewNickName;
	}


	public void setViewNickName(String viewNickName) {
		this.viewNickName = viewNickName;
	}


	public int getViewGroupId() {
		return viewGroupId;
	}


	public void setViewGroupId(int viewGroupId) {
		this.viewGroupId = viewGroupId;
	}


	public UserEntity getUser() {
		return user;
	}


	public void setUser(UserEntity user) {
		this.user = user;
	}

 
	public int getUserId() {
		return userId;
	}


	public void setUserId(int userId) {
		this.userId = userId;
	}


	public IUserService getUserService() {
		return userService;
	}


	public void setUserService(IUserService userService) {
		this.userService = userService;
	}


	public IFriendshipService getFriendshipService() {
		return friendshipService;
	}


	public void setFriendshipService(IFriendshipService friendshipService) {
		this.friendshipService = friendshipService;
	}


	public Map<String, Object> getSession() {
		return session;
	}


	public void setSession(Map<String, Object> session) {
		this.session = session;
	}
}
